package Java实验.实验五;
import java.io.*;

public class CatchException {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String str;
        /********** Begin *********/
        //补全try/catch块，异常类型为IOException
        try {
            System.out.println("输入字符串");
            str=reader.readLine();
            int letter=0;
            int space=0;
            int number=0;
            int other=0;
            for(int i=0;i<str.length();i++){
                if(Character.isLetter(str.charAt(i))){
                    letter++;
                }
                else if(Character.isSpaceChar(str.charAt(i))){
                    space++;
                }
                else if(Character.isDigit(str.charAt(i))){
                    number++;
                }
                else{
                    other++;
                }
            }
            System.out.print("letter="+letter+","+"space="+space+","+"number="+number+","+"other="+other);
            if(str.length()==0){
                throw new IOException();
            }
        }
        catch(IOException e){
            System.out.print("IOException");
        }


        /********** End *********/
    }
}
